package com.javaEE.gamepigeon.controller;


import com.javaEE.gamepigeon.entity.DateDetail;
import com.javaEE.gamepigeon.service.DateDetailService;
import com.javaEE.gamepigeon.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "赛程日期接口")
@RestController
@RequestMapping("/dateDetail")
public class DateDetailController {

    @Autowired
    DateDetailService dateDetailService;


    @ApiImplicitParams({
         //   @ApiImplicitParam(name = "list" ,value = "日期数组",paramType = "body"),
            @ApiImplicitParam(name = "comId",value = "比赛的ID",paramType = "query")
    })
    @PostMapping("/add")
    @ApiOperation("批量添加比赛日期信息")
    public Result addDetail(@RequestBody DateDetail[] list, Integer comId){
        if(list==null||list.length==0||comId==null||comId==0){
            return Result.error("不能为空！");
        }else {
            return dateDetailService.addDetail(list,comId);
        }
    }

//    @ApiImplicitParams({
//        //    @ApiImplicitParam(name="list" , value = "比赛日期的id数组"),
//        //    @ApiImplicitParam(name = "comId",value = "比赛的Id")
//    })
    @ApiOperation("批量删除比赛的日期信息")
    @PostMapping("/delete")
    public Result deleteDetail(@RequestBody Integer[] list, Integer comId){
        if(list.length==0){
            return Result.error("不能为空");
        }else {
            return dateDetailService.deleteDetail(list,comId);
        }
    }

    @ApiOperation("查询对应竞赛的日程")
    @GetMapping("/query")
    public List<DateDetail> queryDetail(Integer comId){
        return dateDetailService.queryDetail(comId);
    }

}
